//链表的回文结构
//思路一：数组法
class PalindromeList {
public:
    bool chkPalindrome(ListNode* A) {
        bool ret = true;
        int count = 0;
        int left, right, i;
        if (!A)
            return ret;
        ListNode* cur = A;
  /*      while (cur) {
            cur = cur->next;
            count++;
        }
        int* arr = (int*)malloc(sizeof(int) * count);
        if (!arr)
            return false;
            cur=A;
        for (i = 0; i < count;i++) {
            arr[i] = cur->val;
            cur = cur->next;
        }        */
        int* arr = (int*)malloc(sizeof(int) * 900);
        if (!arr)
            return false;
        while (cur)
        {
            arr[count++] = cur->val;
            cur = cur->next;
        }
        left = 0;
        right = count - 1;
        while (left < right) {
            if (arr[left] != arr[right]) {
                free(arr);
                arr = NULL;
                return false;
            }
                left++;
                right--;
        }
        free(arr);
        arr = NULL;
        return true;
    }
};